#!/usr/bin/evn python
# -*- coding: utf-8 -*-
from typing import Optional

from fastapi import FastAPI
from pydantic.main import BaseModel

app = FastAPI()


class UserIn(BaseModel):
    username: str
    password: str
    email: str
    full_name: str


class UserOut(BaseModel):
    username: str
    email: str
    full_name: Optional[str] = None


@app.post("/user/", response_model=UserOut)
async def create_user(*, user: UserIn):
    return user


if __name__ == "__main__":
    import uvicorn
    import os

    app_model_name = os.path.basename(__file__).replace(".py", "")
    print(app_model_name)
    uvicorn.run(f"{app_model_name}:app", host='127.0.0.1')
